/* eslint no-unused-vars:0 */
import React from 'react';
import { Row, Col, Icon, message } from 'antd';
import './index.less';

export default class Header extends React.Component {
    //声明变量
    componentWillMount() {}

    logout = () => {
        this.$post('/user/logout')
            .then((res) => {
                if (res.event == 0) {
                    message.success(res.msg);
                    localStorage.jwtToken = '';
                    this.props.history.replace('/');
                } else {
                    message.error(res.msg);
                }
            })
            .catch((e) => {
                console.log(e);
            });
    };

    render() {
        return (
            <div className="header">
                <Row className="header-top">
                    <Col span="14">
                        <div
                            className="head-logo"
                            style={{ fontSize: '26px', float: 'left' }}>
                            <img src="/pic/" alt="" />
                        </div>
                        <span
                            style={{
                                fontSize: '28px',
                                float: 'left',
                                fontWeight: 'bold',
                                color: '#1790ff'
                            }}>
                            高校舆情风险分析平台
                        </span>
                    </Col>
                    <Col span="10">
                        <span>{localStorage.getItem('username')}</span>
                        <a onClick={this.logout}>
                            退出&nbsp;&nbsp;
                            <Icon
                                type="logout"
                                style={{
                                    fontSize: '16px',
                                    marginRight: '10px'
                                }}
                            />
                        </a>
                    </Col>
                </Row>
            </div>
        );
    }
}
